function updateagentedge(k, iter)


global u h m x y dx dy
global Uu Uv Wu Wv Ww


j = round(y(k)/h);
i = round(x(k)/h);

if i > m
    i = m;
    x(k) = m*h;
end
if i < 1
    i = 1;
    x(k) = 1;
end
if j > m
    j = m;
    y(k) = m*h;
end
if j < 1
     j = 1;
    y(k) = 1;
   
end

if iter > 0

    if mod(k,2) == 0
        sg = -1;
    else
        sg = 1;
    end
    
    dx(k) = sg*.2*rand()*Uu(i,j) + (rand() - .5);
    dy(k) = sg*.2*rand()*Uv(i,j) + (rand() - .5);
end


if sqrt(Wu(i,j)^2 + Wv(i,j)^22) > 50 && u(i,j) < 10
    u(i,j) = u(i,j) + 1;
else
    u(i,j) = u(i,j) - 1;
end